package com.webSite.demo.cy.indie.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.webSite.demo.cy.bean.HomeIndex;
import com.webSite.demo.cy.bean.HomeNews;
import com.webSite.demo.cy.mapper.HomeIndexMapper;
import com.webSite.demo.cy.mapper.HomeNewsMapper;

@Controller  
@EnableAutoConfiguration
public class HomeController {

	@Autowired
	HomeIndexMapper homeIndexMapper;
	@Autowired
	HomeNewsMapper homeNewsMapper;
	
	@RequestMapping("/")
    public String home(Model model) {
		//首页信息
		HomeIndex index = homeIndexMapper.findLimitOne();
		model.addAttribute("home", index);
		//首页新闻
		List<HomeNews> list = homeNewsMapper.findAllInfo();
		if(!list.isEmpty()) {
			model.addAttribute("newList", list);
		}
		model.addAttribute("menu", "home");
        return "index";
    }
}
